<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>设置我的密码</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/layuiAdmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/layuiAdmin/style/admin.css" media="all">
  <script src="/js/include.js"></script>
  <script src="/js/rsaEncrypt.js"></script>
</head>
<body>

<div id="app">
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-header">修改密码</div>
          <div class="layui-card-body" pad15>

            <el-form :model="editForm" ref="editForm" :rules="rules" label-width="100px">
              <el-form-item label="当前密码" prop="originalPassword">
                <el-input v-model="editForm.originalPassword" show-password style="width: 200px"></el-input>
              </el-form-item>

              <el-form-item label="新密码" prop="newPassword">
                <el-input v-model="editForm.newPassword" show-password style="width: 200px"></el-input>
              </el-form-item>

              <el-form-item label="确定新密码" prop="renewPassword">
                <el-input v-model="editForm.renewPassword" show-password style="width: 200px"></el-input>
              </el-form-item>

              <el-form-item>
                &nbsp;
                <el-button type="primary" @click="submitForm">确认修改</el-button>
              </el-form-item>
            </el-form>

          </div>
        </div>
      </div>
    </div>
  </div>
</div>
  <script src="/layuiAdmin/layui/layui.js"></script>
  <script>
    let vm = new Vue({
        el: "#app",
        data: {
            editForm: {
                originalPassword: "",
                newPassword: "",
                renewPassword: ""
            },
            rules: {
                originalPassword: [{ required: true, trigger: 'blur', message: '请输入原密码' }],
                newPassword: [{ required: true, trigger: 'blur', message: '请输入新密码' }],
                renewPassword: [{ required: true, trigger: 'blur', message: '请输入确定新密码' }],
            },
        },
        methods: {
            submitForm() {
                let that = this;
                this.$refs["editForm"].validate((valid) => {
                    if (!valid) {
                        return false;
                    }
                    if (that.editForm.newPassword !== that.editForm.renewPassword) {
                        warningMessage("两次输入的密码不一致！");
                        return;
                    }
                    let originalPassword = RSA_ENCRYPT(that.editForm.originalPassword);
                    let newPassword = RSA_ENCRYPT(that.editForm.newPassword);

                    myConfirm("确定提交？", function () {
                        showLoading("保存中....");
                        myAjax({
                            type: "post",
                            url: BASE_PATH + "/sys/updatePassword",
                            data: {
                                originalPassword: originalPassword,
                                newPassword: newPassword,
                            },
                            callback: function () {
                                hideLoading();
                                successMessage("修改成功！");
                            }
                        })
                    })

                });

            },
        }

    })
  </script>
  <script>
  layui.config({
    base: '/layuiAdmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  });
  </script>
</body>
</html>